package com.itheima.d6_tcp3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;

public class CilentThread implements Runnable{
    private Socket socket;

    public CilentThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        //读取内容
        //获取输入流

        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while (true){
                String s = br.readLine();//阻塞
                System.out.println("收到服务端消息："+s);
                if(s!=null){
                    System.out.println(br+":"+s);
                }
                }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
